Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More ntp servers #4448

Merged
merged 8 commits into from
Dec 18, 2024
Merged

Conversation

christoph-zededa
Copy link
Contributor

@christoph-zededa christoph-zededa commented Nov 26, 2024

  • allow setting more than one NTP server
  • allow setting NTP servers by domain (instead of just ip)
  • allow ignoring NTP servers from DHCP server

@christoph-zededa christoph-zededa force-pushed the more_ntp_servers branch 4 times, most recently from 2b8af39 to 6d83fea Compare November 27, 2024 16:12
@christoph-zededa christoph-zededa force-pushed the more_ntp_servers branch 4 times, most recently from 6c070b3 to 94174f9 Compare December 2, 2024 18:16
@@ -103,6 +137,7 @@ func (z *zedrouter) getNIPortConfig(
if port == nil {
continue
}
basicNTPServerIPs, _ := types.GetNTPServers(*z.deviceNetworkStatus, port.IfName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be less confusing if getNIPortConfig didn't set NTPServers at all (not even the already resolved IPs) and would leave this to attachNTPServersToPortConfigs.
Then also please add a comment for getNIPortConfig mentioning that NTP servers are set separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@github-actions github-actions bot requested a review from milan-zededa December 4, 2024 13:49
@christoph-zededa christoph-zededa force-pushed the more_ntp_servers branch 4 times, most recently from 8ff6cd8 to cabff85 Compare December 9, 2024 13:32
@christoph-zededa christoph-zededa changed the title WIP: More ntp servers More ntp servers Dec 10, 2024
@christoph-zededa christoph-zededa force-pushed the more_ntp_servers branch 3 times, most recently from 5e5507d to abba1ec Compare December 10, 2024 12:31
@christoph-zededa christoph-zededa marked this pull request as ready for review December 11, 2024 13:14
@OhmSpectator
Copy link
Member

Argh, I will try to review it soon...

Makefile Outdated Show resolved Hide resolved
pkg/pillar/cmd/zedagent/parseconfig.go Outdated Show resolved Hide resolved
ntpServers = append(ntpServers, ip)
continue
}
dnsResponses, err := devicenetwork.ResolveWithPortsLambda(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long time can this call take? Any risk of a watchdog due to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout is specified here: https://github.com/lf-edge/eve/blob/master/pkg/pillar/devicenetwork/dns.go#L35

Last week I tested the code with more than 10 unreachable NTP servers and I did not notice the watchdog to get triggered.

Do we run zedrouter without watchdog? - https://github.com/lf-edge/eve/blob/master/pkg/pillar/cmd/zedrouter/zedrouter.go#L175 as I don't see a agentbase.WithWatchdog(...).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We kick of the main watchdog for each agent in device-steps.sh
touch "$WATCHDOG_FILE/$AGENT.touch"

Wouldn't the delay be if there are potentially unreachable/slow DNS servers and there are 10 NTP servers configured with a domain name that needs to be resolved?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, now I understand (better) how this works.
I added a call to pubSub.StillRunning(...): https://github.com/lf-edge/eve/compare/2a16d63887c83fbe4ffe5bec74b3a435b0f7f5f2..b9a29770fc4d1103a007ba1bbe3286172047bf4f

func ResolveCacheWrap(resolve func(string, net.IP, net.IP) ([]DNSResponse, error)) func(domain string, dnsServerIP net.IP, srcIP net.IP) ([]DNSResponse, error) {
return func(domain string, dnsServerIP net.IP, srcIP net.IP) ([]DNSResponse, error) {

dnsResponses, found := resolveCache[domain]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we resolve these globally?
Suppose wwan0 is a walled garden and it has a DNS server on 10.10.10.10 and eth0 is a different walled garden. Then if the configured ntp server domainname is ntp.corp for both wwan0 and eth0 don't we need to ensure that we do the DNS lookup out the correct network interface?

IP addresses and globally unique and visible domain names don't have that issue, but resolving domain names can't assume that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end chronyd and dnsmasq do not care about the different interfaces, do they?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the map key a combination of domain and source ip.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dnsmasq is for the applications doing DNS resolution. We configure chronyd with IP addresses. My concern is about the DNS resolution of the NTP server names. Note that we have been resolving the standard pool.ntp.org without worrying about walled gardens, but as we allow the users to specify domain names for NTP servers they might be using ones which are inside their walled garden(s). I'll take a look at your map approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* allow setting more NTP servers through controller
* allow setting NTP server by domain instead of just IP address
  (problem: we only resolve the domains once at the beginning)

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
Don't use _test for the package name of tests, because
this disallows accessing private methods

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
which makes pillar ignore NTP servers provided by
the DHCP server on that particular interface

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
@christoph-zededa christoph-zededa force-pushed the more_ntp_servers branch 3 times, most recently from 57ac8b1 to 2a16d63 Compare December 17, 2024 14:12
Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but still need to see if we the DNS resolutions of lots of names can take too long for the watchdog.
Kick off tests.

continuously in the background so that updated
IP addresses can be used if the edge application is
restarted (from controller)

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
This will update the network instance if the network config
changes; for example during re-activation of the edge app.

It is necessary as we want to resolve the IP addresses of
the NTP servers again on re-activation of the edge app.

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
e.g. run `sudo make TAP=tap0 run` to not autoconfigure
the second interface and just let it run as a tap device.

You then have to bring your own dhcp server and setup
everything manually.

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
Need to bump eve-api after following PR
lf-edge/eve-api#77

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
to the controller so that the controller knows that EVE
can handle domain names and not just IP addresses

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
@christoph-zededa
Copy link
Contributor Author

Kick off tests.

Sorry, I saw that too late and force-pushed ...

Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run tests

@eriknordmark eriknordmark merged commit fa93b4d into lf-edge:master Dec 18, 2024
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants